package com.qf.logistics.dto;

import com.qf.logistics.exceptions.MyErrorCode;
import org.springframework.stereotype.Component;

/**
 * created by 赵文韬 on 2022/4/1 20:21
 */
@Component
public class R {
    private int code;
    private String msg;
    private Object data;
    public static R setOK(){
        return setOK(null);
    }
    public static R setError(){
        return setError(null);
    }
    public static R setOK(Object data){
        return getR(MyErrorCode.SUCCESS,"成功",data );
    }
    public static R setError(Object data){
        return getR(MyErrorCode.FAIL,"失败" ,data );
    }
    public static R getR(int code,String msg,Object data){
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
